package com.bong.panpan.bongcharttools.custom;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * Created by panpan on 2018/1/7.
 */

public class ObjectSaveUtil {
    public static void saveCache(Object object, String fileName) throws Exception {
        ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(Constant.cachePath + "/" + fileName));
        stream.writeObject(object);
        stream.close();
    }

    public static Object readCache(String fileName) throws Exception {
        ObjectInputStream stream = new ObjectInputStream(new FileInputStream(Constant.cachePath + "/" + fileName));
        Object object = stream.readObject();
        stream.close();
        return object;
    }
}
